package com.xinhe.web.controller;

import com.querydsl.core.QueryResults;
import com.xinhe.web.common.Result;
import com.xinhe.web.entity.OrderLogistics;
import com.xinhe.web.request.OrderLogisticsModel;
import com.xinhe.web.service.OrderLogisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Api(value = "订单物流", tags = {"订单物流"})
@RestController
@RequestMapping(value = {"/orderLogistics"}, produces = {"application/json;charset=UTF-8"})

public class OrderLogisticsController {
    @Autowired
    private OrderLogisticsService orderLogisticsService;

    @ApiOperation(httpMethod = "GET", value = "分页查询订单物流")
    @RequestMapping({"/pageOrderLogistics"})
    public QueryResults<OrderLogistics> pageOrderLogistics(int pageNum, int pageSize) {
        return this.orderLogisticsService.pageOrderLogistics(pageNum,pageSize);
    }
    @ApiOperation(httpMethod = "POST", value = "保存订单物流")
    @RequestMapping({"/saveOrderLogistics"})
    public Result saveOrderLogistics(@Valid OrderLogisticsModel model) {
        return this.orderLogisticsService.saveModel(model);
    }

    @ApiOperation(httpMethod = "GET", value = "删除订单物流")
    @ApiImplicitParam(name = "orderLogisticsId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/deleteOrderLogistics"})
    public Result deleteOrderLogistics(Long orderLogisticsId) {
        return this.orderLogisticsService.delete(orderLogisticsId);
    }

    @ApiOperation(httpMethod = "GET", value = "订单物流详情")
    @ApiImplicitParam(name = "orderLogisticsId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/detailOrderLogistics"})
    public Result detailOrderLogistics(Long orderLogisticsId) {
        return this.orderLogisticsService.findById(orderLogisticsId);
    }

}
